import http from '@/utils/http'

export async function apiGetProjects(args = {}) {
  const url = '/projects'
  const params = {
    page: 1,
    size: 50,
    ...args,
  }
  const { data = { list: [], total: 0 } } = await http.get(url, params)
  return data
}

export async function apiGetProjectById(id = '') {
  const url = '/projects/' + id
  const { data = {} } = await http.get(url)
  return data
}

export async function apiAddProject(args = {}) {
  const url = '/projects'
  const params = {
    title: '',
    desc: '',
    ...args,
  }
  const { data: id = '' } = await http.post(url, params)
  return id
}

export async function apiUpdateProject(id = '', args = {}) {
  const url = '/projects/' + id
  const params = {
    title: '',
    desc: '',
    ...args,
  }
  await http.put(url, params)
}

export async function apiRemoveProject(id = '') {
  const url = '/projects/' + id
  await http.delete(url)
}
